<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */

 echo '<h2 class="toggler"><span class="buildLine">Správce bottomblock</span></h2>';
 echo '<div class="element">';

if(empty($_GET['a'])){
echo '<table cellspacing="15" cellpadding="15">';
echo '<tr><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'] .'&mod=bottom&a=new"><img src="../libs/icons/add.png" /> Vytvořit položku </a></td></tr>';
echo '</table><br />';

$query = $GLOBALS['db']->query("SELECT * FROM ".$GLOBALS['db_prefix']."bottomblock");
echo '<table cellspacing="15" cellpadding="15">';
echo '<tr><th>Typ</th><th>Text</th><th>Cesta</th><th>Váha</th><th>Aktivní</th><th>Akce</th></tr>';
while($data = $query->fetch_array()){
    $active = ($data['active'] == 1) ? 'tick.png' : 'exclamation.png';
	echo '<tr><td>'.$data['type'].'</td><td>'.$data['text'].'</td><td>'.$data['module_path'].'</td><td>'.$data['weigh'].'</td><td><img src="../libs/icons/'.$active.'" /></td><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&mod=top&a=delete&id='.$data['id'].'"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&mod=topt&a=edit&id='.$data['id'].'"><img src="../libs/icons/style_edit.png" /></a></td></tr>';
}
echo '</table></div>';
}else {
	switch($_GET['a']){
		case 'new':
		require 'new.php';
		break;

		case 'delete':
		require 'delete.php';
		break;

		case 'edit':
		require 'edit.php';
		break;
	}
}
?>